import mysql.Mysql;


/**
 * Class GameUser
 */
public class GameUser {

	//
	// Fields
	//

	private Game game;
	private User user;
	private int gold;
	private int color;

	//
	// Constructors
	//
	public GameUser() {
	};

	public void setUser(User newVar) {
		user = newVar;
	}

	public User getUser() {
		return user;
	}

	public void setGame(Game game) {
		this.game = game;
	}

	/**
	 * Set the value of gold
	 * 
	 * @param newVar
	 *            the new value of gold
	 */
	public void setGold(int newVar) {
		gold = newVar;
	}

	/**
	 * Get the value of gold
	 * 
	 * @return the value of gold
	 */
	public int getGold() {
		return gold;
	}

	public int getColor() {
		return color;
	}

	public void setColor(int color) {
		this.color = color;
	}

	//
	// Other methods
	//
	
	public void save() {
		Mysql bd = new Mysql();
		String strsql;
		
		
		strsql = "insert into tb_games_users (game_id, user_id, gold, color) values " +
				 "(" +this.game.getId() +","+this.user.getId()+","+this.gold+","+this.color+")";
		
		bd.insertUpdate(strsql);
	}

}
